package net.sudot.chess.business.controller.web;

import net.sudot.chess.business.controller.AbstractBaseController;
import net.sudot.chess.constant.SessionConstants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * 二维码接口控制器
 *
 * @author tangjialin on 2018-03-25.
 */
@Controller
@RequestMapping("/qrcode")
public class QRCodeController extends AbstractBaseController {

    /**
     * 邀请好友
     *
     * @param userId 邀请者(用户主键)
     * @return 返回携带邀请信息的页面
     */
    @GetMapping("/invite/{inviter}")
    public String vipCode(@PathVariable("inviter") Long userId, HttpServletRequest request) {
        request.getSession().setAttribute(SessionConstants.INVITE_RECORD_INVITER, userId);
        return "redirect:/";
    }

}